Skip to content

Refactor all plugin subdirectories to use functional options pattern#308

Draft
Copilot wants to merge 2 commits intorefactor-pluginfrom
copilot/modify-plugin-files-subdirectories
Draft

Refactor all plugin subdirectories to use functional options pattern#308
Copilot wants to merge 2 commits intorefactor-pluginfrom
copilot/modify-plugin-files-subdirectories

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 9, 2026

Applies the functional options pattern established in plugin/singbox to all remaining plugin subdirectories.

Pattern

Each plugin type now follows a consistent structure:

// Unexported struct
type mrs_in struct { ... }

// Constructor with variadic options for programmatic use
func NewMRSIn(action lib.Action, opts ...lib.InputOption) lib.InputConverter

// Option functions
func WithNameAndURI(name, uri string) lib.InputOption
func WithInputDir(dir string) lib.InputOption

// JSON deserialization delegates to constructor
func NewMRSInFromBytes(action lib.Action, data []byte) (lib.InputConverter, error)

Changes

  • plugin/mihomo: MRSInmrs_in, MRSOutmrs_out
  • plugin/plaintext: TextIntext_in, TextOuttext_out (+ all extension files: clash, json, surge)
  • plugin/maxmind: GeoLite2CountryMMDBIn/Out, GeoLite2ASNCSVIn, GeoLite2CountryCSVIn → unexported equivalents (+ dbip/ipinfo extension files)
  • plugin/v2ray: GeoIPDatIngeoIPDatIn, GeoIPDatOutgeoIPDatOut
  • plugin/special: Cutter, Lookup, Private, Stdin, Stdout → unexported equivalents
  • lookup.go, merge.go: Replace direct struct literals with constructor calls

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Apply the same functional options pattern from plugin/singbox to:
- plugin/mihomo (mrs_in.go, mrs_out.go)
- plugin/plaintext (text_in.go, common_in.go, common_out.go, text_out.go, clash_in.go, clash_out.go, json_in.go, surge_in.go, surge_out.go)
- plugin/maxmind (all input/output files)
- plugin/v2ray (dat_in.go, dat_out.go)
- plugin/special (cutter.go, lookup.go, private.go, stdin.go, stdout.go)
- lookup.go and merge.go updated to use new constructors

Co-authored-by: Loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com>
Copilot AI changed the title [WIP] Modify files in subdirectories of plugin package Refactor all plugin subdirectories to use functional options pattern Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants